//
//  TravelRouteViewController.m
//  HZHome
//
//  Created by Alawn on 13-10-10.
//  Copyright (c) 2013年 xzysun. All rights reserved.
//

#import "TravelRouteViewController.h"
#import "TravelRouteCell.h"
#import "TravelRouteNextViewController.h"
@interface TravelRouteViewController ()

@end

@implementation TravelRouteViewController
@synthesize listTitleData;
@synthesize listContentData;
@synthesize listImgTitleData;
@synthesize listImage;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    NSArray *arrayTitle = [[NSArray alloc] initWithObjects:@"情品海珠 · 扬爱国情怀" ,@"绿品海珠 · 拥绿意自然", @"炫品海珠 · 叹都市惊艳",@"雅品海珠 · 悟宗教民俗",nil];
    NSArray *arrayImgTitle = [[NSArray alloc] initWithObjects:@"路线一" ,@"路线二", @"路线三", @"路线四",nil];
    NSArray *arrayContentTitle = [[NSArray alloc] initWithObjects:@"孙中山大元帅府 - 廖仲恺、何香凝纪念馆 - 邓世昌纪念馆 - 十香园纪念馆 - 潘鹤雕塑艺术园 - 粤海第 一关纪念馆",
                                  @"潘鹤雕塑艺术园 - 海珠湿地公园 - 海珠湖 - 小洲村 - 瀛洲生态公园",
                                  @"黄埔古港古村 - 琶洲国际会展中心 - T.I.T创意园 - 珠江琶醍啤酒文化创意艺术区景 - 广州塔",
                                  @"太古仓码头 - 海幢寺 - 基督教河南堂 - 纯阳观 - 黄埔古村北帝庙",nil];
    NSArray *images = [[NSArray alloc] initWithObjects:@"01.png",@"02.png",
                       @"03.png",@"04.png",nil];
    
    self.listTitleData = arrayTitle;
    self.listImage = images;
    self.listImgTitleData=arrayImgTitle;
    self.listContentData=arrayContentTitle;
    if (self.config!=nil) {
        NSString *myValue=[self.config objectForKey:@"key"];
        self.title=myValue;
    } else {
        self.title = @"预约";

    }
}

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationItem.leftBarButtonItem = nil;
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (void)viewDidUnload {
    [super viewDidUnload];
    self.listTitleData = nil;
    self.listImage = nil;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [self tableView:tableView cellForRowAtIndexPath:indexPath];
    return cell.frame.size.height;
}
#pragma mark -- 实现TableView数据源方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return [listTitleData count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    TravelRouteCell *myCell = (TravelRouteCell*)[tableView dequeueReusableCellWithIdentifier:@"TravelRouteCell"];
    if (myCell == nil) {
        myCell = [[[NSBundle mainBundle] loadNibNamed:@"TravelRouteCell" owner:self options:nil]objectAtIndex:0];
    }
    NSUInteger row = [indexPath row];
    UIImage *img = [UIImage imageNamed:[listImage objectAtIndex:row]];
    myCell.routeImageView.image=img;
    myCell.labelContent.text=[listContentData objectAtIndex:row];
    myCell.labelImageTitle.text=[listImgTitleData objectAtIndex:row];
    myCell.labelTitle.text=[listTitleData objectAtIndex:row];
    [myCell setBackgroundColor:[UIColor clearColor]];
    [myCell.contentView setBackgroundColor:[UIColor clearColor]];

    return myCell;
//    static NSString *SimpleCellIdentifier = @"SimpleCellIdentifier";
//    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:SimpleCellIdentifier];
//    
//    if (cell == nil) {
//        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
//                                       reuseIdentifier:SimpleCellIdentifier];
////        cell=[UITableViewCell alloc]
//    }
//    NSUInteger row = [indexPath row];
//    cell.textLabel.text = [listData objectAtIndex:row];
//    UIImage *img = [UIImage imageNamed:[listImage objectAtIndex:row]];
//    cell.imageView.image = img;
//    return cell;
}
#pragma mark -- 实现TableView委托方法
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSUInteger row = [indexPath row];
    NSString *rowValue = [listImgTitleData objectAtIndex:row];
    TravelRouteNextViewController *vc = [[TravelRouteNextViewController alloc]initWithNibName:@"TravelRouteNextViewController" bundle:nil];
    vc.routeType=rowValue;
    vc.title=[listTitleData objectAtIndex:row];
    [self.navigationController pushViewController:vc animated:YES];
//    NSString *message = [[NSString alloc] initWithFormat:@"你选择了%@队。", rowValue];
//    
//    UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"行选择"
//                                                   message:message
//                                                  delegate:self
//                                         cancelButtonTitle:@"Ok"
//                                         otherButtonTitles:nil];
//    [alert show];
//    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}


@end
